use "obs_survey2020.dta"


*Figure 1 & Table A4 (models 1&2)

reg soc_dist_ind01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) replace
margins, at(demrep3=0) saving("socdist1a", replace)
margins, at(demrep3=1) saving("socdist2a", replace)
margins, at(demrep3=2) saving("socdist3a", replace)
margins, at(socdist_commnolead_ind01=0) saving("socdist4a", replace)
margins, at(socdist_commnolead_ind01=1) saving("socdist5a", replace)

combomarginsplot socdist1a socdist2a socdist3a socdist4a socdist5a , recast(scatter) horiz labels( "Democrat" "Independent"  "Republican" "Perceived norms - low" "Perceived norms - high",  labsize(small)) yscale(range(.5 5.5)) ///
ytitle("") xtitle("Predicted social distancing behavior") title("Social distancing behavior") fysize(90) fxsize(130) yline(3.5, lpattern(shortdash)) scheme(s2mono)
graph save fig1a_comb.gph, replace


reg support_govt_socdist_policy01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) append
margins, at(demrep3=0) saving("sdpol1a", replace)
margins, at(demrep3=1) saving("sdpol2a", replace)
margins, at(demrep3=2) saving("sdpol3a", replace)
margins, at(socdist_commnolead_ind01=0) saving("sdpol4a", replace)
margins, at(socdist_commnolead_ind01=1) saving("sdpol5a", replace)

combomarginsplot sdpol1a sdpol2a sdpol3a sdpol4a sdpol5a , recast(scatter) horiz labels(" " " " " " " " " " " " " ",  labsize(small)) yscale(range(.5 5.5)) xscale(range(.5 .8)) ///
ytitle("") xtitle("Predicted social distancing support") title("Social distancing policy support") fysize(90) fxsize(90) yline(3.5, lpattern(shortdash)) scheme(s2mono)
graph save fig1b_comb.gph, replace

graph combine "fig1a_comb" "fig1b_comb", title("Figure 1: Partisanship vs. local norms: behavioral and attitudinal effects", size(medium)) col(2) scheme(s2mono)
graph save fig1_comb.gph, replace

/// note("Predicted values and 95% confidence intervals. All regressions control for demographics and a state-level index of social distanting restrictions. See Table A3 for full regression results."


*Figures 2a&2b & Table A4(models 3&4)

reg soc_dist_ind01 c.socdist_commnolead_ind01##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) append
margins, dydx(socdist_commnolead_ind01) at(demrep3=(0 1 2))
margins, dydx(i.demrep3) at(socdist_commnolead_ind01=(0 .5 1))
margins, at(socdist_commnolead_ind01=(0 .25 .5 .75 1 ) demrep3=(0 1 2)) 
marginsplot, ytitle("Social distancing behavior") xtitle("Local social distancing support") plot1opts(msymbol(O) mcolor(blue) lcolor(blue)) plot2opts(msymbol(T) mcolor(purple) lcolor(purple)) plot3opts(msymbol(S) mcolor(red) lcolor(red)) ///
ci1opts(color(blue)) ci2opts(color(purple)) ci3opts(color(red)) yscale(range(.35 1)) ylabel(.4 (.2)1) ///
title("Fig 2a: Partisanship, perceived local norms and social distancing behavior", size(medsmall)) 
graph save Graph "fig 2a socdist behav vs perceived local norms by partisanship.gph", replace

reg support_govt_socdist_policy01 c.socdist_commnolead_ind01##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) append
margins, dydx(socdist_commnolead_ind01) at(demrep3=(0 1 2))
margins, dydx(i.demrep3) at(socdist_commnolead_ind01=(0 .5 1))
margins, at(socdist_commnolead_ind01=(0 .25 .5 .75 1 ) demrep3=(0 1 2)) 
marginsplot, ytitle("Social distancing support") xtitle("Local social distancing support") ///
plot1opts(msymbol(O) mcolor(blue) lcolor(blue)) plot2opts(msymbol(T) mcolor(purple) lcolor(purple)) plot3opts(msymbol(S) mcolor(red) lcolor(red)) ///
ci1opts(color(blue)) ci2opts(color(purple)) ci3opts(color(red))  yscale(range(0 1)) ylabel(0 (.2)1) ///
title("Fig 2b: Partisanship, perceived local norms and social distancing support", size(medsmall))
graph save Graph "fig 2b socdist support vs perceived local norms by partisanship.gph", replace

*Figure 5 & Table A4(models 5&6) 

*Role of objective local behavior is roughly twice as large for Independents but it's also significant for Dems 
reg socdist_commnolead_ind01 c.retail_rec_reduct01 i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) replace
margins, dydx(retail_rec_reduct01) level(90) saving("norms1", replace)

reg socdist_commnolead_ind01 c.retail_rec_reduct01##demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba4_main, label word symbol(**,*,#) bdec(3) append
margins, dydx(retail_rec_reduct01) at(demrep=0) level(90) saving("norms12", replace) 
margins, dydx(retail_rec_reduct01) at(demrep=1) level(90) saving("norms13", replace)
margins, dydx(retail_rec_reduct01) at(demrep=2) level(90) saving("norms14", replace)

combomarginsplot norms14 norms13 norms12 norms1 , recast(scatter) horiz labels(  "Republican" "Independent" "Democrat" "All respondents",  labsize(small)) yscale(range(.5 4.5)) ///
ytitle("") xtitle("Marginal effect of local mobility reductions") title("Fig.5 Local behavior, partisanship, and perceived norms")  xline(0, lpattern(shortdash)) scheme(s2mono)

/// note("The figure shows the marginal effect and 95% confidence intervals of county-level mobility changes since the start of the pandemic on perceived local norms for different groups. For full results see Table A4 in appendix")

*Additional appendix tables

**Table A1 - Summary stats for July 2020 survey
summ soc_dist_ind01 support_govt_socdist_policy01 socdist_commnolead_ind01 retail_rec_reduct01 i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, sep(0)
summ soc_dist_ind01 support_govt_socdist_policy01 socdist_commnolead_ind01 retail_rec_reduct01 b2.demrep3 b2.race5 b2.educ4 income age female deaths_chg7_perk state_restrict_ind, sep(0)

*Table A5 - Robustness tests

reg soc_dist_ind01 c.socdist_commnolead_ind01##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) replace

reg support_govt_socdist_policy01 c.socdist_commnolead_ind01##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg soc_dist_ind01 c.socdist_commnolead_ind01##i.demrep3 c.socdist_commnolead_ind01##c.covid_news_ind i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg support_govt_socdist_policy01 c.socdist_commnolead_ind01##i.demrep3 c.socdist_commnolead_ind01##c.covid_news_ind i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg soc_dist_ind01 c.socdist_commnolead_ind01##i.demrep3 c.socdist_commnolead_ind01##i.news_cons i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg support_govt_socdist_policy01 c.socdist_commnolead_ind01##i.demrep3 c.socdist_commnolead_ind01##i.news_cons i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg soc_dist_ind01 c.socdist_commnolead_ind01##i.demrep3 c.trump_shr##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

reg support_govt_socdist_policy01 c.socdist_commnolead_ind01##i.demrep3 c.trump_shr##i.demrep3 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba5_robustness, label word symbol(**,*,#) bdec(3) append

*Table A8
reg sd_fact1_01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) replace

reg sd_fact2_01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg avoid_restaurant01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg avoid_retail01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg avoid_entertain01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg wash_hands01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg dist_6ft01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg wore_mask01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

reg stay_home01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba8_FAtests, label word symbol(**,*,#) bdec(3) append

		
*Table A9 - community norms components robustness tests

reg soc_dist_ind01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask usage intention) bdec(3) replace 

reg soc_dist_ind01 i.demrep3 socdist_support_fam01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask usage intention) bdec(3) append 

reg soc_dist_ind01 i.demrep3 socdist_support_othercomm01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask usage intention) bdec(3) append

reg support_govt_socdist_policy01 i.demrep3 socdist_commnolead_ind01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask mandate support) bdec(3) append

reg support_govt_socdist_policy01 i.demrep3 socdist_support_fam01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask mandate support) bdec(3) append

reg support_govt_socdist_policy01 i.demrep3 socdist_support_othercomm01 i.race5 i.educ4 income age female deaths_chg7_perk state_restrict_ind, cluster(fips)
outreg2 using taba9_locnorm_comp, label word symbol(**,*,#) ctitle(Mask mandate support) bdec(3) append
 